﻿using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization.Formatters.Binary;


namespace Estimate
{


    public partial class formAdminSettings : FormMDIChildTemplate
    {
        const string EXTENSION = "Estimate";

        public formAdminSettings()
        {
            InitializeComponent();
        }

        private void buttonBackup_Click(object sender, EventArgs e)
        {
            DateTime dateNow = DateTime.Now;
            if (context.Connection.State != ConnectionState.Open) context.Connection.Open();
            System.Data.Common.DbCommand command = context.Connection.CreateCommand();
            command.CommandText = String.Format("BACKUP DATABASE {0} TO DISK='{1}/{0}-{2}.bak' ",
                context.Connection.Database, Application.StartupPath, DateTime.Now.ToString("yyyy-MMdd-HHmm"));
            try { command.ExecuteNonQuery(); formMain.ShowInformation("Файл Створено"); }
            catch { formMain.ShowError("Помилка при Створенні Файлу"); }
        }
       
    }

  
}
